#define DEBUG
#include <cstdio>
#define MAXN 500

using namespace std;

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif

  static bool map[MAXN+1][MAXN+1];
  static int f[MAXN+1][MAXN+1], g[2][MAXN+1][MAXN+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=m; j++) {
      char c;
      scanf(" %c ", &c);
      map[i][j] = c=='.';
      g[0][i][j] = g[0][i-1][j]+(map[i][j] && map[i][j-1]);
      g[1][i][j] = g[1][i][j-1]+(map[i][j] && map[i-1][j]);
      f[i][j] = f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(map[i][j] && map[i-1][j])+(map[i][j] && map[i][j-1]);
    }
  }

  int q;
  scanf("%d", &q);
  for (int i=1; i<=q; i++) {
    int x1, y1, x2, y2, ans;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    ans = f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1]-g[0][x2][y1]+g[0][x1-1][y1]-g[1][x1][y2]+g[1][x1][y1-1];
    printf("%d\n", ans);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
